<?php

namespace App\Http\Requests\Admin\Customer\Product;

use App\Http\Requests\ApiRequest;
use App\Services\Utils\Guard;
use Illuminate\Validation\Rule;

/**
 * @property string name
 * @property string sort
 */
class CosmeticMaterialStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $customer_id = Guard::customer()->id;

        return [
            'name' => ['required', 'string', 'max:' . self::MAX_STRING, Rule::unique('cosmetic_materials', 'name')
                ->where('customer_id', $customer_id)],
            'sort' => 'nullable|int|between:0,10000',
        ];
    }
}
